package com.leyou.item.clients;

import com.leyou.dto.PageDTO;
import com.leyou.item.dto.*;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

/**
 * @author ：qcq
 * @date ：Created in 2020/12/12 19:28
 * @description：
 */
@FeignClient("item-service")
public interface ItemClient {

    /**
     * 分页查询spu
     *
     * @param
     * @return
     */
    @GetMapping("/goods/spu/page")
    PageDTO<SpuDTO> findPage(@RequestParam(value = "page", defaultValue = "1") Integer page,
                             @RequestParam(value = "rows", defaultValue = "5") Integer rows,
                             @RequestParam(value = "saleable", required = false) Boolean saleable,
                             @RequestParam(value = "brandId", required = false) Long brandId,
                             @RequestParam(value = "categoryId", required = false) Long categoryId,
                             @RequestParam(value = "id", required = false) Long id);

    /**
     * 根据spuID查询sku的集合
     *
     * @param id
     * @return
     */
    @GetMapping("/goods/sku/of/spu")
    List<SkuDTO> querySkuBySpuId(@RequestParam("id") Long id);

    /**
     * 根据商品id（spuId）查询对应的规格参数组集合以及组内参数的信息，及对应值
     *
     * @param spuId
     * @param searching
     * @return
     */
    @GetMapping("/goods/spec/value")
    List<SpecParamDTO> listSpec(
            @RequestParam("id") Long spuId,
            @RequestParam(value = "searching", required = false) Boolean searching);

    /**
     * 通过ids查询分类集合
     * @param ids
     * @return
     */
    @GetMapping("/category/list")
    List<CategoryDTO> queryCategoryByIdList(@RequestParam List<Long> ids);

    /**
     * 通过ids查询品牌集合
     * @param ids
     * @return
     */
    @GetMapping("/brand/list")
    List<BrandDTO> queryBrandListByIds(@RequestParam("ids") List<Long> ids);

    /**
     * 根据id查询spu及sku、spuDetail等
     *
     * @param id
     * @return
     */
    @GetMapping("/goods/{id}")
    SpuDTO querySkuAndSpuAndApuDetailById(@PathVariable("id") Long id);

    /**
     * 根据id查询商品
     *
     * @param id
     * @return
     */
    @GetMapping("/goods/spu/{id}")
    SpuDTO queryGoodsById(@PathVariable("id") Long id);

    /**
     * 根据id查询商品详情
     *
     * @param id
     * @return
     */
    @GetMapping("/goods/spu/detail")
    SpuDetailDTO querySpuDetailBySpuId(@RequestParam("id") Long id);


    @GetMapping("/brand/{id}")
    BrandDTO queryBrandById(@PathVariable("id") Long id);

    //根据分类id查询规格组及组内参数
    @GetMapping("/spec/list")
    List<SpecGroupDTO> querySpecGroupAndParamByCategoryId(@RequestParam("id") Long id);



}
